/*********************************************************************************/
/*                                                                               */
/*      MCU Driver                                                               */
/*                                                                               */
/*      Last updated by:  CBS                                                    */
/*      Last update date: 13/01/25                                               */
/*      Revision:         0                                                      */
/*      Copyright:        DENSO                                                  */
/*                                                                               */
/*********************************************************************************/

#ifndef MCU_H
#define MCU_H

/*********************************************************************************/
/*  include files                                                                */
/*********************************************************************************/
#include "Std_Types.h"
#include "Mcu_Cfg.h"

/*********************************************************************************/
/*  defines / data types / structs / unions / macros                             */
/*********************************************************************************/
#define MCU_VENDOR_ID        (U2)1
#define MODULE_ID_MCU        (U2)101
#define MCU_INSTANCE_ID      (U1)0

#define MCU_SW_MAJOR_VERSION (U1)1
#define MCU_SW_MINOR_VERSION (U1)0
#define MCU_SW_PATCH_VERSION (U1)0

#define MCU_AR_MAJOR_VERSION (U1)1
#define MCU_AR_MINOR_VERSION (U1)0
#define MCU_AR_PATCH_VERSION (U1)0

/* Service ID */
#define MCU_INIT_SERVICE_ID                 0x00
#define MCU_INITRAMSECTION_SERVICE_ID       0x01
#define MCU_INITCLOCK_SERVICE_ID            0x02
#define MCU_DISTRIBUTEPLLCLOCK_SERVICE_ID   0x03
#define MCU_GETPLLSTATUS_SERVICE_ID         0x04
#define MCU_GETVERSIONINFO_SERVICE_ID       0x09

/* Error Codes */
#define MCU_E_PARAM_CONFIG                  0x0A
#define MCU_E_PARAM_CLOCK                   0x0B
#define MCU_E_PARAM_MODE                    0x0C
#define MCU_E_PARAM_RAMSECTION              0x0D
#define MCU_E_PLL_NOT_LOCKED                0x0E
#define MCU_E_UNINIT                        0x0F
#define MCU_E_PARAM_POINTER                 0x10


typedef enum
{
    MCU_PLL_LOCKED,
    MCU_PLL_UNLOCKED,
    MCU_PLL_STATUS_UNDEFINED
}Mcu_PllStatusType;

typedef struct
{
    U4 McuClockReferencePointFrequency;                    /* MCU175_Conf */
    U1 McuEnhancedPreDivider;                              /* EPREDIV */
    U1 McuEnhancedMultiplicationFactorDivider;             /* EMFD */
    U1 McuEnhancedReducedFrequencyDivider;                 /* ERFD */
}Mcu_ClockSettingConfigType;

typedef struct
{
    /* This parameter shall represent the number of clock setting available for the MCU. */
    U1 McuClockSettings;

    /* This parameter defines the default clock settings that should be used. It is an index into the McuClockSettingsConfig. */
    Mcu_ClockType McuDefaultClockSettings;

    /* MCU031 */
    /* This container contains the configuration (parameters) for the Clock settings of the MCU. */
    Mcu_ClockSettingConfigType * McuClockSettingConfig;
}Mcu_ConfigType;

/*********************************************************************************/
/*  API Functions                                                             */
/*********************************************************************************/

/***************************************************************************************************/
/*  Service name    :   Mcu_Init                                                                   */
/*  Sync/Async      :   Synchronous                                                                */
/*  Reentrancy      :   Non Reentrant                                                              */
/*  Parameters (in) :   Pointer to MCU driver configuration.                                       */
/*  Return value    :   None                                                                       */
/*  Discription     :   This service initializes the MCU driver.                                   */
/***************************************************************************************************/
void Mcu_Init(const Mcu_ConfigType* ConfigPtr);

/***************************************************************************************************/
/*  Service name    :   Mcu_InitClock                                                              */
/*  Sync/Async      :   Synchronous                                                                */
/*  Reentrancy      :   Non Reentrant                                                              */
/*  Parameters (in) :   ClockSetting      Clock Setting                                            */
/*  Return value    :   Std_ReturnTpye    E_OK: command has been accepted.                         */
/*                                        E_NOT_OK: command has not been accepted.                 */
/*  Discription     :   This service initializes the PLL and other MCU specific clock options.     */
/***************************************************************************************************/
Std_ReturnType Mcu_InitClock(Mcu_ClockType ClockSetting);

/***************************************************************************************************/
/*  Service name    :   Mcu_GetPllStatus                                                           */
/*  Sync/Async      :   Synchronous                                                                */
/*  Reentrancy      :   Reentrant                                                                  */
/*  Parameters (in) :   None                                                                       */
/*  Return value    :   Mcu_PllStatusType    PLL Status                                            */
/*  Discription     :   This service provides the lock status of the PLL.                          */
/***************************************************************************************************/
Mcu_PllStatusType Mcu_GetPllStatus(void);

/********************************************************************************************************/
/*  Service name    :   Mcu_GetVersionInfo                                                              */
/*  Sync/Async      :   Synchronous                                                                     */
/*  Reentrancy      :   Reentrant                                                                       */
/*  Parameters (in) :   versioninfo   Pointer to where to store the version information of this module. */
/*  Return value    :   None                                                                            */
/*  Discription     :   This service returns the version information of this module.                    */
/********************************************************************************************************/
#if(MCU_VERSION_INFO_API == STD_ON)  /* MCU104 */
void Mcu_GetVersionInfo(Std_VersionInfoType* versioninfo);
#endif  /* MCU_VERSION_INFO_API */

#endif  /* MCU_H */
/**** End Of File ****************************************************************/
